class Solution {
    public:
        vector<int> getAverages(vector<int>& nums, int k) {
            int n = nums.size();
            long long sum = 0;
            vector<int> ans(n, -1);
            if (k * 2 + 1 > n) {
                return ans;
            }
            for (int i = 0; i < 2 * k + 1; i++) {
                sum += nums[i];
            }
            for (int i = k; i + k < n; ++i) {
                if(i!=k){
                    sum += nums[i + k] - nums[i - k - 1];
                }
                ans[i] = sum / (k * 2 + 1);
            }
            return ans;
        }
    };
    
    